package week3.gateway.client;

import okhttp3.Request;
import okhttp3.Response;

import java.io.IOException;

public class OkHttpClient {
    static okhttp3.OkHttpClient client = new okhttp3.OkHttpClient();
    static String header;
    static String run(String url) throws IOException {

        Request request = new Request.Builder()
                .url(url)
                .build();

        try (Response response = client.newCall(request).execute()) {
            header = response.header("aim").toString();
            return response.body().string();
        }
    }

    public static void main(String[] args) throws IOException {
        String body = run("http://localhost:8808/test");
        System.out.println(body);
        System.out.println("The header added by the filter is: ");
        System.out.println(header);
    }
}
